package com.analyse.stock.controller;

import com.analyse.stock.service.IStockKlineService;
import com.analyse.stock.vo.ResultUtils;
import com.analyse.stock.vo.ResultVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/stockKline")
public class StockKlineController {

    @Autowired
    private IStockKlineService stockKlineService;

    /**
     * 获取某一只股票的日周月年K线
     */
    @GetMapping("/getHistory")
    public ResultVo<Integer> getDaily(@RequestParam(name="stockCode") String stockCode) {
        Integer num = stockKlineService.getStockKlineHistoryByEastMoney(stockCode);
        return ResultUtils.ok(num);
    }

    /**
     * 增量获取日K
     */
    @GetMapping("/getLatest")
    public ResultVo<Integer> getLatest(@RequestParam(name="stockCode") String stockCode,@RequestParam(name="date") String date) {
        Integer num = stockKlineService.getLatest(stockCode,date);
        return ResultUtils.ok(num);
    }
}
